<?php
include DOXCX_FRAME_PATH.'controller/admin/index.php';

$mu = Session::get('mu');
if(!$mu->isadmin){
	if(!in_array('1',json_decode($mu->app_auth))){
		unset($index['微信开发']);
	}
	if(!in_array('2',json_decode($mu->app_auth))){
		unset($index['支付宝']);
	}
	if(!in_array('3',json_decode($mu->app_auth))){
		unset($index['百度开发']);
	}
	if(!in_array('4',json_decode($mu->app_auth))){
		unset($index['头条抖音']);
	}
	if(!in_array('5',json_decode($mu->app_auth))){
		unset($index['QQ小程序']);
	}
}

$m = new Model('user_menu');
$m->find(['pid'=>$mu->id]);
$menuname=json_decode($m->menuname,1);
$menusort=json_decode($m->menusort,1);
if(Request::post()){
	unset($_POST['btnAdd']);
	$m->pid = $mu->id;
	$m->menuname = json_encode($_POST,320);
	$m->save();
	tusi('设置成功');
	Redirect::delay_to('menuname',1);
}

if($m->id){
	foreach($index as $k=>$m){
		$index[$k]['id']=$menusort[$k];
		if($menuname[$k]){
			$index[$k]['name']=$menuname[$k];
		}
	}
	if(count($menusort)){
		array_multisort(array_column($index,'id'),SORT_ASC,$index);
	}
}

